package com.cskaoyan.controller.wx;

import com.cskaoyan.bean.BaseRespVo;
import com.cskaoyan.bean.bo.AftersaleSubmitBO;
import com.cskaoyan.bean.bo.OrderListWxBO;
import com.cskaoyan.bean.pojo.MarketOrder;
import com.cskaoyan.bean.pojo.MarketOrderGoods;
import com.cskaoyan.bean.vo.AfterSaleDetailVO;
import com.cskaoyan.bean.vo.AfterSaleListWxVO;
import com.cskaoyan.service.AfterSaleWxService;
import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 订单售后
 *
 * @author chenxu
 * @since 2022/04/11 15:18
 */
@RestController
@RequestMapping("wx/aftersale")
public class AftersaleController {

    @Autowired
    AfterSaleWxService afterSaleService;
    //售后状态，0是可申请，1是用户已申请，2是管理员审核通过，3是管理员退款成功，4是管理员审核拒绝，5是用户已取消

    //订单售后信息
    @RequestMapping("list")
    public BaseRespVo list( OrderListWxBO afterSaleBO){

      AfterSaleListWxVO afterSaleListWxVO = afterSaleService.list(afterSaleBO);

        return BaseRespVo.ok(afterSaleListWxVO);
    }

    //售后详情
    @RequestMapping("detail")
    public BaseRespVo detail(MarketOrderGoods orderGoods){
       AfterSaleDetailVO saleDetailVO = afterSaleService.detail(orderGoods.getOrderId());
       return BaseRespVo.ok(saleDetailVO);
    }

    @PostMapping("submit")
    public BaseRespVo submit(@RequestBody AftersaleSubmitBO submitBO){
        afterSaleService.submit(submitBO);
        return BaseRespVo.ok();
    }

}
